<?php

class WorkflowNode extends BaseModel
{

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'node';
	}
	
	public function relations() 
	{
        return array(
            'workflow'  =>  array(self::BELONGS_TO, 'Workflow', 'workflow_id'),
        );
    }
    
    public function getActionClass() {
    	$configure = unserialize($this->node_configuration);
    	if(is_array($configure)) {
    		return $configure['class'];
    	}
    }
    
    public function getActionArguments() {
    	$configure = unserialize($this->node_configuration);
    	if(is_array($configure)) {
    		return CJSON::encode($configure['arguments']);
    	}
    }

    /**
     * 
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'node_id' => '编号',
            'node_class' => '结点名',
        );
    }

}
